Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the server challenge request (Linux based servers), fixes #47 #51

Merged
merged 1 commit into from
May 13, 2022
Merged

Support the server challenge request (Linux based servers), fixes #47 #51

merged 1 commit into from
May 13, 2022

Conversation

ThePoShWolf
Copy link
Contributor

PR Summary

Fixes #47 - Supports the server challenge (https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO). Tested and still works on Windows based servers.

Context

When querying a Linux based Rust server, I was getting a 9 bytes response which turned out to be the 4 byte header, the byte indicating a challenge ('A' or 0x41) followed by the challenge bytes themselves. To handle this and get the requested data, the client needs to send the query again with the challenge appended.

See the steam docs for further details.

Changes

If the first byte of the stream (after the headers) is the challenge indicator, then resend the original query with the challenge bytes appended.

This change was made it Get-SteamServerInfo.ps1.

Checklist

  • Pull Request has a meaningful title.
  • Summarised changes.
  • Pull Request is ready to merge & is not WIP.
  • Added tests / only testable interactively.
    • Make sure you add a new test if old tests do not effectively test the code changed.
  • Added documentation / opened issue to track adding documentation at a later date.

@hjorslev hjorslev self-assigned this May 11, 2022
@hjorslev hjorslev added Category-Module Pertaining to the module's functionality itself. Issue-Bug 🐛 Something's wrong! labels May 11, 2022
@hjorslev
Copy link
Owner

Thans so much for this PR!

I will merge and release it this weekend 😊

@hjorslev hjorslev merged commit 60da818 into hjorslev:master May 13, 2022
@hjorslev hjorslev mentioned this pull request May 13, 2022
5 tasks
@hjorslev
Copy link
Owner

hjorslev commented May 13, 2022

@ThePoShWolf

After the new release when I query my server it skips the first letter of the server name (correct name should be SAS Proving Ground 12 (EU)):

Protocol      : 83
ServerName    : AS Proving Ground 12 (EU)
Map           : PowerStation
InstallDir    : groundbranch
GameName      : Ground Branch
AppID         : 0
Players       : 0
MaxPlayers    : 10
Bots          : 0
ServerType    : Dedicated
Environment   : Windows
Visibility    : Public
VAC           : Unsecured
Version       : 1.0.0.0
ExtraDataFlag : 177
IPAddress     : 185.15.73.207
Port          : 27015

If I change $ReceivedData = $Client.Receive([Ref]$IPEndpoint) | Select-Object -Skip 4 to $ReceivedData = $Client.Receive([Ref]$IPEndpoint) | Select-Object -Skip 3 it seems to work.

Could I get you to review that solution for me and test against a linux based server?

@ThePoShWolf
Copy link
Contributor Author

@hjorslev - That is strange. Here's the output if I -Skip 3:

Protocol      : 73
ServerName    : ◄Land of the Toddomites
Map           : Procedural Map
InstallDir    : rust
GameName      : Rust
AppID         : 0
Players       : 0
MaxPlayers    : 10
Bots          : 0
ServerType    : Dedicated
Environment   : Linux
Visibility    : Public
VAC           : Secured
Version       : 2336
ExtraDataFlag : 177
IPAddress     : 20.236.47.160
Port          : 28015

There is an extra character in the server name.

If I switch back to -Skip 4, then the protocol changes as well:

Protocol      : 17
ServerName    : Land of the Toddomites
...

I'm not sure what is happening, but when I have more time this weekend I can try digging into that a bit deeper. Feel free to use my server IP above for testing.

@ThePoShWolf
Copy link
Contributor Author

@hjorslev I figured it out. In Get-SteamServerInfo line 85, the if statement is doing a ReadByte(), so it moves the position forward by one. All it takes to fix is an else with: $Stream.BaseStream.Position = 0. I'll submit a new PR.

@ThePoShWolf
Copy link
Contributor Author

#53 submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category-Module Pertaining to the module's functionality itself. Issue-Bug 🐛 Something's wrong!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get-SteamServerInfo Cmdlet fails for linux based "The Isle" servers
2 participants